package com.jt.mapper;


import com.jt.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;

import java.util.List;

public interface UserMapper {
    @Select("select * from user")
    List<User> findAll();
    @Select("select * from user where username=#{username} and password=#{password}")
    User findUserByUP(User user);
    @Select("select count(1) from user")
    long getTotal();
    List<User> findUserListByPage(@Param("start") int start,
                                  @Param("size") int size,
                                  @Param("query") String query);
   /* @Select("select * from user limit #{start},#{size}")
    List<User> findUserListByPage(@Param("start") int start,@Param("size") int size);*/

    @Update("update user set status = #{status},updated = #{updated} where id=#{id}")
    void updateStatus(User user);

    void addUser(User user);

    @Select("select * from user where id=#{id}")
    User findUserById(Integer id);

    @Update("update user set phone=#{phone},email=#{email} where id=#{id}")
    void updateUser(User user);

    @Delete("delete from user where id=#{id}")
    void deleteUserById(Integer id);
}
